home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3006
/
3006.xpi
/
chrome
/
dwhelper.jar
/
content
/
widgets.xml
< prev
next >
Wrap
Extensible Markup Language
|
2010-01-15
|
21KB
|
797 lines
<?xml version="1.0"?>
<!-- *****************************************************************************
* Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
****************************************************************************** -->
<!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
//dump("Widget\n");
this.util=Components.classes["@downloadhelper.net/util-service;1"]
.getService(Components.interfaces.dhIUtilService);
this.NS="http://downloadhelper.net/1.0#";
this.prefObservers={};
this.mapAnonid();
var prefService=Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.pref=prefService.getBranch("semioscape.");
this.mediaListMgr=Components.classes["@downloadhelper.net/media-list-manager"]
.getService(Components.interfaces.dhIMediaListMgr);
this.convertMgr=Components.classes["@downloadhelper.net/convert-manager-component"]
.getService(Components.interfaces.dhIConvertMgr);
//dump("Calling handleXBLPersist\n");
try {
this.handleXBLPersist();
//dump("Called handleXBLPersist\n");
} catch(e) {
dump("!!! [Widget] constructor: calling handleXBLPersist:"+e+"\n");
}
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<method name="mapAnonid">
<body>
<![CDATA[
var nodes=document.getAnonymousNodes(this);
for(var i=0;i<nodes.length;i++) {
var node=nodes[i];
this.mapAnonidRec(node);
}
]]>
</body>
</method>
<method name="mapAnonidRec">
<parameter name="node"/>
<body>
<![CDATA[
if(node.nodeType==Node.ELEMENT_NODE) {
var anonid=node.getAttribute("anonid");
if(anonid!=null && anonid.length>0) {
//this.debugln("[widget] mapAnonidRec: map "+anonid);
this[anonid]=node;
node.parentXBL=this;
//this.debugln("[widget] mapAnonidRec: element "+node.tagName+" has parentXBL "+node.parentXBL);
}
node=node.firstChild;
while(node!=null) {
this.mapAnonidRec(node);
node=node.nextSibling;
}
}
]]>
</body>
</method>
<method name="getAnonNodes">
<parameter name="attr"/>
<body>
<![CDATA[
var aNodes=[];
var nodes=document.getAnonymousNodes(this);
for(var i=0;i<nodes.length;i++) {
var node=nodes[i];
this.getAnonNodesRec(node, attr, aNodes);
}
return aNodes;
]]>
</body>
</method>
<method name="getAnonNodesRec">
<parameter name="node"/>
<parameter name="attr"/>
<parameter name="aNodes"/>
<body>
<![CDATA[
if(node.nodeType==Node.ELEMENT_NODE) {
var aValue=node.getAttribute(attr);
if(aValue!=null && aValue.length>0) {
aNodes.push(node);
}
node=node.firstChild;
while(node!=null) {
this.getAnonNodesRec(node,attr,aNodes);
node=node.nextSibling;
}
}
]]>
</body>
</method>
<method name="fireEvent">
<parameter name="evType"/>
<body>
<![CDATA[
var evt = document.createEvent("Events");
evt.initEvent(evType, true, true);
var sendEvent=function(_this,evt) {
_this.dispatchEvent(evt);
}
setTimeout(sendEvent,0,this,evt);
]]>
</body>
</method>
<method name="sendEvent">
<parameter name="evType"/>
<body>
<![CDATA[
var evt = document.createEvent("Events");
evt.initEvent(evType, true, true);
this.dispatchEvent(evt);
]]>
</body>
</method>
<method name="getLocalStore">
<body>
<![CDATA[
if(this.localstore==null) {
this.localstore=Components.classes["@mozilla.org/rdf/datasource;1?name=local-store"].
getService(Components.interfaces.nsIRDFDataSource);
}
return this.localstore;
]]>
</body>
</method>
<method name="handleXBLPersist">
<body>
<![CDATA[
//dump("handleXBLPersist "+this.tagName+"\n");
var pNodes=this.getAnonNodes("xbl-persist");
//dump("handleXBLPersist: got "+pNodes.length+" nodes\n");
var prefix="";
if(this.hasAttribute("xbl-persist-prefix"))
prefix=this.getAttribute("xbl-persist-prefix");
for(var i=0;i<pNodes.length;i++) {
var node=pNodes[i];
var value=node.getAttribute("xbl-persist");
var parts=/^(.*?):(.*)$/.exec(value);
if(parts!=null && parts.length==3) {
var name=prefix+parts[1];
var attrs=parts[2].split(",");
for(var j=0;j<attrs.length;j++) {
var lsRes=this.NS+"xbl-persist-node-"+name;
var lsProp=this.NS+"xbl-persist-attribute-"+attrs[j];
var value=this.util.getPropertyValueSS(this.getLocalStore(),
lsRes,lsProp);
//dump("Loading "+lsRes+" "+lsProp+" "+value+"\n");
if(value!=null)
node.setAttribute(attrs[j],value);
}
}
}
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="DOMAttrModified">
<![CDATA[
//dump("DOMAttrModified "+this.tagName+": "+event.originalTarget.getAttribute("anonid")+" attribute "+event.attrName+" "+event.prevValue+"=>"+event.newValue+"\n");
if(this.doMonitorXBLPersist!=true)
return;
var node=event.originalTarget;
if(!node.hasAttribute("xbl-persist"))
return;
var prefix="";
if(this.hasAttribute("xbl-persist-prefix"))
prefix=this.getAttribute("xbl-persist-prefix");
var value=node.getAttribute("xbl-persist");
var parts=/^(.*?):(.*)$/.exec(value);
if(parts!=null && parts.length==3) {
var name=prefix+parts[1];
var attrs=parts[2].split(",");
for(var j=0;j<attrs.length;j++) {
if(attrs[j]==event.attrName) {
var lsRes=this.NS+"xbl-persist-node-"+name;
var lsProp=this.NS+"xbl-persist-attribute-"+attrs[j];
//dump("Saving "+lsRes+" "+lsProp+" "+event.newValue+"\n");
this.util.setPropertyValueSS(this.getLocalStore(),
lsRes,lsProp,event.newValue);
}
}
}
]]>
</handler>
</handlers>
</binding>
<!-- ******************************************************************************************** -->
<binding id="ExtList" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox flex="1">
<listbox anonid="listbox" flex="1" onselect="this.parentNode.parentNode.select()"
seltype="multiple" style="height: 60px;"/>
<hbox>
<textbox anonid="textbox"
onkeyup="this.parentNode.parentNode.parentNode.keypress()"
/>
<button anonid="add-button" label="&button.add;" oncommand="this.parentNode.parentNode.parentNode.add()" disabled="true"/>
</hbox>
<hbox>
<button label="&button.default;" oncommand="this.parentNode.parentNode.parentNode.setDefault()"/>
<button anonid="remove-button" label="&button.remove;" disabled="true" oncommand="this.parentNode.parentNode.parentNode.remove()"/>
</hbox>
</vbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.listbox=document.getAnonymousElementByAttribute(this,"anonid","listbox");
this.textbox=document.getAnonymousElementByAttribute(this,"anonid","textbox");
this.removeButton=document.getAnonymousElementByAttribute(this,"anonid","remove-button");
this.addButton=document.getAnonymousElementByAttribute(this,"anonid","add-button");
]]>
</constructor>
<method name="add">
<body>
<![CDATA[
var ext=this.textbox.value;
if(ext=="")
return;
this.addExt(ext);
]]>
</body>
</method>
<method name="addExt">
<parameter name="ext"/>
<body>
<![CDATA[
if(ext==null|| ext=="")
return;
var listitem=document.createElement("listitem");
listitem.setAttribute("label",ext);
this.listbox.appendChild(listitem);
]]>
</body>
</method>
<method name="select">
<body>
<![CDATA[
if(this.listbox.selectedItems.length==0) {
this.removeButton.setAttribute("disabled","true");
} else {
this.removeButton.setAttribute("disabled","false");
}
]]>
</body>
</method>
<method name="remove">
<body>
<![CDATA[
if(this.listbox.selectedItems.length==0)
return;
while(this.listbox.selectedItems.length>0) {
var tbd=this.listbox.selectedItems[0];
var item=this.listbox.firstChild;
while(item!=null) {
if(item==tbd) {
this.listbox.removeChild(item);
break;
}
item=item.nextSibling;
}
}
this.fireEvent("change");
]]>
</body>
</method>
<method name="keypress">
<body>
<![CDATA[
var text=this.textbox.value;
if(text.length==0 || this.hasExt(text))
this.addButton.setAttribute("disabled","true");
else
this.addButton.setAttribute("disabled","false");
]]>
</body>
</method>
<method name="hasExt">
<parameter name="ext"/>
<body>
<![CDATA[
var item=this.listbox.firstChild;
while(item!=null) {
if(item.getAttribute("label")==ext)
return true;
item=item.nextSibling;
}
]]>
</body>
</method>
<method name="clear">
<body>
<![CDATA[
while(this.listbox.firstChild)
this.listbox.removeChild(this.listbox.firstChild);
]]>
</body>
</method>
<method name="setDefault">
<body>
<![CDATA[
if(this.hasAttribute("defaults")) {
var def=this.getAttribute("defaults");
this.setData(def);
} else if(this.hasAttribute("preference")) {
var prefName=document.getElementById(this.getAttribute("preference")).getAttribute("name");
var prefService=Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefService.clearUserPref(prefName);
this.setData(prefService.getCharPref(prefName));
}
]]>
</body>
</method>
<method name="setData">
<parameter name="def"/>
<body>
<![CDATA[
this.clear();
var exts=def.split("|");
for(var i=0;i<exts.length;i++)
this.addExt(exts[i]);
this.fireEvent("change");
]]>
</body>
</method>
<method name="getData">
<body>
<![CDATA[
var exts=[];
var item=this.listbox.firstChild;
while(item!=null) {
exts.push(item.getAttribute("label"));
item=item.nextSibling;
}
return exts.join("|");
]]>
</body>
</method>
<property name="value">
<setter>
<![CDATA[
this.setData(val);
]]>
</setter>
<getter>
<![CDATA[
var data=this.getData();
return data;
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="BlackList" extends="widgets.xml#ExtList">
<implementation>
<constructor>
<![CDATA[
]]>
</constructor>
<method name="add">
<body>
<![CDATA[
var ext=this.textbox.value;
if(ext=="")
return;
if(!/^([0-9a-zA-Z\-_]+\.)+[0-9a-zA-Z\-_]+$/.test(ext)) {
this.util.alertError(this.util.getText("blacklist.error.invalid-hostname"));
return;
}
this.addExt(ext);
]]>
</body>
</method>
</implementation>
</binding>
<binding id="TextboxEnabled" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox>
<vbox>
<spacer flex="1"/>
<html:input type="checkbox" anonid="xEnable" onchange="this.parentNode.parentNode.parentNode.changedEnabled()"/>
<spacer flex="1"/>
</vbox>
<textbox anonid="xTextbox" flex="1" style="visibility:hidden;"/>
</hbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
]]>
</constructor>
<property name="value">
<setter>
<![CDATA[
if(val==null || val.length==0) {
this.xEnable.checked=false;
this.xTextbox.value="";
this.xTextbox.style.visibility="hidden";
} else {
this.xEnable.checked=true;
this.xTextbox.value=val;
this.xTextbox.style.visibility="visible";
}
]]>
</setter>
<getter>
<![CDATA[
if(this.xEnable.checked)
return this.xTextbox.value;
else
return "";
]]>
</getter>
</property>
<method name="changedEnabled">
<body>
<![CDATA[
if(this.xEnable.checked) {
this.xTextbox.style.visibility="visible";
if(this.hasAttribute("defvalue"))
this.xTextbox.value=this.getAttribute("defvalue");
} else {
this.xTextbox.style.visibility="hidden";
}
]]>
</body>
</method>
</implementation>
</binding>
<binding id="KeyEditor" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox>
<menulist anonid="xModifier">
<menupopup>
<menuitem value="1" label="CTRL"/>
<menuitem value="3" label="SHIFT+CTRL"/>
<menuitem value="6" label="SHIFT+ALT"/>
<menuitem value="5" label="CTRL+ALT"/>
<menuitem value="7" label="CTRL+SHIFT+ALT"/>
</menupopup>
</menulist>
<menulist anonid="xKey">
<menupopup>
<menuitem value="VK_CANCEL" label="CANCEL"/>
<menuitem value="VK_BACK" label="BACK"/>
<menuitem value="VK_TAB" label="TAB"/>
<menuitem value="VK_CLEAR" label="CLEAR"/>
<menuitem value="VK_RETURN" label="RETURN"/>
<menuitem value="VK_ENTER" label="ENTER"/>
<menuitem value="VK_PAUSE" label="PAUSE"/>
<menuitem value="VK_ESCAPE" label="ESCAPE"/>
<menuitem value="VK_SPACE" label="SPACE"/>
<menuitem value="VK_PAGE_UP" label="PAGE_UP"/>
<menuitem value="VK_PAGE_DOWN" label="PAGE_DOWN"/>
<menuitem value="VK_END" label="END"/>
<menuitem value="VK_HOME" label="HOME"/>
<menuitem value="VK_LEFT" label="LEFT"/>
<menuitem value="VK_UP" label="UP"/>
<menuitem value="VK_RIGHT" label="RIGHT"/>
<menuitem value="VK_DOWN" label="DOWN"/>
<menuitem value="VK_PRINTSCREEN" label="PRINTSCREEN"/>
<menuitem value="VK_INSERT" label="INSERT"/>
<menuitem value="VK_DELETE" label="DELETE"/>
<menuitem value="VK_0" label="0"/>
<menuitem value="VK_1" label="1"/>
<menuitem value="VK_2" label="2"/>
<menuitem value="VK_3" label="3"/>
<menuitem value="VK_4" label="4"/>
<menuitem value="VK_5" label="5"/>
<menuitem value="VK_6" label="6"/>
<menuitem value="VK_7" label="7"/>
<menuitem value="VK_8" label="8"/>
<menuitem value="VK_9" label="9"/>
<menuitem value="VK_SEMICOLON" label="SEMICOLON"/>
<menuitem value="VK_EQUALS" label="EQUALS"/>
<menuitem value="VK_A" label="A"/>
<menuitem value="VK_B" label="B"/>
<menuitem value="VK_C" label="C"/>
<menuitem value="VK_D" label="D"/>
<menuitem value="VK_E" label="E"/>
<menuitem value="VK_F" label="F"/>
<menuitem value="VK_G" label="G"/>
<menuitem value="VK_H" label="H"/>
<menuitem value="VK_I" label="I"/>
<menuitem value="VK_J" label="J"/>
<menuitem value="VK_K" label="K"/>
<menuitem value="VK_L" label="L"/>
<menuitem value="VK_M" label="M"/>
<menuitem value="VK_N" label="N"/>
<menuitem value="VK_O" label="O"/>
<menuitem value="VK_P" label="P"/>
<menuitem value="VK_Q" label="Q"/>
<menuitem value="VK_R" label="R"/>
<menuitem value="VK_S" label="S"/>
<menuitem value="VK_T" label="T"/>
<menuitem value="VK_U" label="U"/>
<menuitem value="VK_V" label="V"/>
<menuitem value="VK_W" label="W"/>
<menuitem value="VK_X" label="X"/>
<menuitem value="VK_Y" label="Y"/>
<menuitem value="VK_Z" label="Z"/>
<menuitem value="VK_NUMPAD0" label="NUMPAD0"/>
<menuitem value="VK_NUMPAD1" label="NUMPAD1"/>
<menuitem value="VK_NUMPAD2" label="NUMPAD2"/>
<menuitem value="VK_NUMPAD3" label="NUMPAD3"/>
<menuitem value="VK_NUMPAD4" label="NUMPAD4"/>
<menuitem value="VK_NUMPAD5" label="NUMPAD5"/>
<menuitem value="VK_NUMPAD6" label="NUMPAD6"/>
<menuitem value="VK_NUMPAD7" label="NUMPAD7"/>
<menuitem value="VK_NUMPAD8" label="NUMPAD8"/>
<menuitem value="VK_NUMPAD9" label="NUMPAD9"/>
<menuitem value="VK_MULTIPLY" label="MULTIPLY"/>
<menuitem value="VK_ADD" label="ADD"/>
<menuitem value="VK_SEPARATOR" label="SEPARATOR"/>
<menuitem value="VK_SUBTRACT" label="SUBTRACT"/>
<menuitem value="VK_DECIMAL" label="DECIMAL"/>
<menuitem value="VK_DIVIDE" label="DIVIDE"/>
<menuitem value="VK_F1" label="F1"/>
<menuitem value="VK_F2" label="F2"/>
<menuitem value="VK_F3" label="F3"/>
<menuitem value="VK_F4" label="F4"/>
<menuitem value="VK_F5" label="F5"/>
<menuitem value="VK_F6" label="F6"/>
<menuitem value="VK_F7" label="F7"/>
<menuitem value="VK_F8" label="F8"/>
<menuitem value="VK_F9" label="F9"/>
<menuitem value="VK_F10" label="F10"/>
<menuitem value="VK_F11" label="F11"/>
<menuitem value="VK_F12" label="F12"/>
<menuitem value="VK_F13" label="F13"/>
<menuitem value="VK_F14" label="F14"/>
<menuitem value="VK_F15" label="F15"/>
<menuitem value="VK_F16" label="F16"/>
<menuitem value="VK_F17" label="F17"/>
<menuitem value="VK_F18" label="F18"/>
<menuitem value="VK_F19" label="F19"/>
<menuitem value="VK_F20" label="F20"/>
<menuitem value="VK_F21" label="F21"/>
<menuitem value="VK_F22" label="F22"/>
<menuitem value="VK_F23" label="F23"/>
<menuitem value="VK_F24" label="F24"/>
<menuitem value="VK_NUM_LOCK" label="NUM_LOCK"/>
<menuitem value="VK_SCROLL_LOCK" label="SCROLL_LOCK"/>
<menuitem value="VK_COMMA" label="COMMA"/>
<menuitem value="VK_PERIOD" label="PERIOD"/>
<menuitem value="VK_SLASH" label="SLASH"/>
<menuitem value="VK_BACK_QUOTE" label="BACK_QUOTE"/>
<menuitem value="VK_OPEN_BRACKET" label="OPEN_BRACKET"/>
<menuitem value="VK_BACK_SLASH" label="BACK_SLASH"/>
<menuitem value="VK_CLOSE_BRACKET" label="CLOSE_BRACKET"/>
<menuitem value="VK_QUOTE" label="QUOTE"/>
<menuitem value="VK_HELP" label="HELP"/>
</menupopup>
</menulist>
</hbox>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.updateKeyLocales();
]]>
</constructor>
<method name="updateKeyLocales">
<body>
<![CDATA[
var menuitem=this.xModifier.firstChild.firstChild;
while(menuitem!=null) {
var keys=[];
for(var i=0;i<3;i++) {
if(menuitem.getAttribute("value") & (1<<i))
keys.push(this.util.getText("processor.quickkey.key"+i));
}
menuitem.setAttribute("label",keys.join("+"));
menuitem=menuitem.nextSibling;
}
]]>
</body>
</method>
<property name="value">
<getter>
<![CDATA[
return this.xModifier.value+";"+this.xKey.value;
]]>
</getter>
<setter>
<![CDATA[
var keyParts=val.split(";",2);
this.key=keyParts[1];
if(!/^VK_/.test(this.key))
this.key="VK_"+this.key;
this.xKey.value=this.key;
this.modifier=keyParts[0];
this.xModifier.value=this.modifier;
]]>
</setter>
</property>
</implementation>
</binding>
<binding id="ProcessorMenulist" extends="widgets.xml#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menulist anonid="xProcessors">
<menupopup anonid="xProcPopup"/>
</menulist>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.core=Components.classes["@downloadhelper.net/core;1"].
getService(Components.interfaces.dhICore);
var processors=this.core.getProcessors();
var i=processors.enumerate();
while(i.hasMoreElements()) {
var processor=i.getNext().QueryInterface(Components.interfaces.dhIProcessor);
var menuitem=document.createElement("menuitem");
menuitem.setAttribute("label",processor.title);
menuitem.setAttribute("value",processor.name);
this.xProcPopup.appendChild(menuitem);
}
]]>
</constructor>
<property name="value">
<getter>
<![CDATA[
return this.xProcessors.value;
]]>
</getter>
<setter>
<![CDATA[
this.xProcessors.value=val;
]]>
</setter>
</property>
</implementation>
</binding>
<binding id="DHPassword" extends="#widget">
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<textbox anonid="xPassword" type="password"/>
<children style="display: none;"/>
</xbl:content>
<implementation>
<constructor>
<![CDATA[
this.mValueSet=false;
]]>
</constructor>
<destructor>
<![CDATA[
]]>
</destructor>
<property name="value">
<getter>
<![CDATA[
return this.xPassword.value;
]]>
</getter>
<setter>
<![CDATA[
this.xPassword.value=val;
this.mValueSet=true;
]]>
</setter>
</property>
<property name="valueSet">
<getter>
<![CDATA[
return this.mValueSet;
]]>
</getter>
</property>
<property name="disabled">
<getter>
<![CDATA[
return this.xPassword.disabled;
]]>
</getter>
<setter>
<![CDATA[
this.xPassword.disabled=val;
]]>
</setter>
</property>
</implementation>
</binding>
</bindings>